/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.continuousPointModel;

import java.io.Serializable;
import java.util.ArrayList;

import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IVector;
import br.ufmg.dees.insane.util.geometricProperties.GeometricProperties;
import br.ufmg.dees.insane.util.pointValues.PointValues;
import br.ufmg.dees.insane.util.pointValues.StringPointValues;

/** A class representing EulerPoint
 * @author CENOURA!!!
 * @since 14/12/2005
 */
public class EulerPoint implements ContinuousPointModel, Serializable {
    
	private static final long serialVersionUID = 1L;

	/**Constructs a Euler Point Analysis Model.*/
    public EulerPoint()
    {
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getInternalVariableOperator(IMatrix d, IMatrix d2, IVector n, IMatrix c) {
        IMatrix le = new IMatrix(3,4);
        le.setZero();
        le.setElement(0,0,1.0);
        le.setElement(0,2,c.getElement(2,0));
        le.setElement(0,3,-c.getElement(1,0));
        le.setElement(1,1,-c.getElement(2,0));
        le.setElement(2,1,c.getElement(1,0));
        return le;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix, br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getInternalVariableOperator(IMatrix d, IMatrix d2, IVector n, IMatrix c,
            IMatrix u) {
        IMatrix le = new IMatrix(3,4);
        le.setZero();
        le.setElement(0,0,1.0);
        le.setElement(0,2,c.getElement(2,0));
        le.setElement(0,3,-c.getElement(1,0));
        le.setElement(1,1,-c.getElement(2,0));
        le.setElement(2,1,c.getElement(1,0));
        return le;
    }
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#modifyInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix modifyInternalVariableOperator(IMatrix e, IMatrix m) {
        return e;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getDualInternalVariableOperator(IMatrix e) {
        IMatrix D = new IMatrix (3,3);
        D.setZero();
        D.setElement(0,0,e.getElement(0,0));
        D.setElement(1,1,e.getElement(3,3));
        D.setElement(2,2,e.getElement(4,4));
        return D;
    }
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#modifyDualInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, java.util.ArrayList)
     */
	public IMatrix modifyDualInternalVariableOperator(IMatrix e, GeometricProperties gps)	{
		return e;
	}

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getStateVariableOperator(br.ufmg.dees.insane.util.IVector)
     */
    public IMatrix getStateVariableOperator(IMatrix d, IVector n, IMatrix c) {
    	IMatrix lu = new IMatrix(3,6);
        lu.setZero();
        lu.setElement(0,0,1);
        lu.setElement(1,1,1);
        lu.setElement(2,2,1);
        lu.setElement(0,4,c.getElement(2,0));
        lu.setElement(0,5,-c.getElement(1,0));
        lu.setElement(1,3,-c.getElement(2,0));
        lu.setElement(2,3,c.getElement(1,0));
        return lu;
    }
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getNumberOfInternalVariables()
     */
    public int getNumberOfInternalVariables() {
        return 3;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getNumberOfDualInternalVariables()
     */
    public int getNumberOfDualInternalVariables() {
        return 3;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariablesVector(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IVector getInternalVariablesVector(IVector a, IMatrix b) {
        return a;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariablesVector(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IVector getDualInternalVariablesVector(IVector a, IMatrix b) {
        return a;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariablesTensor(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getInternalVariablesTensor(IVector a, IMatrix b) {
        IMatrix epsilonTensor = new IMatrix(3,3);
        epsilonTensor.setZero();
        epsilonTensor.setElement(0,0,a.getElement(0));
        epsilonTensor.setElement(0,1,a.getElement(1));
        epsilonTensor.setElement(0,2,a.getElement(2));
        epsilonTensor.setElement(1,0,a.getElement(1));
        epsilonTensor.setElement(2,0,a.getElement(2));
        return epsilonTensor;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariablesTensor(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getDualInternalVariablesTensor(IVector a, IMatrix b) {
        return expandTensor(a); 
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariablesDirLabels()
     */
    public String[] getInternalVariablesLabels() {
        String[] Dlabels = {"EPSILONxx", "GAMAxy", "GAMAxz"};
        return Dlabels;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariablesDirLabels()
     */
    public String[] getDualInternalVariablesLabels() {
        String[] Tlabels =  {"SIGMAxx", "TAOxy", "TAOxz"};
        return Tlabels;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#expandVector(br.ufmg.dees.insane.util.IVector)
     */
    public IVector expandVector(IVector a) {
        IVector Vector = new IVector(6);
        Vector.zero();
        Vector.setElement(0,a.getElement(0));
        Vector.setElement(3,a.getElement(1));
        Vector.setElement(4,a.getElement(2));
        return Vector;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#expandTensor(br.ufmg.dees.insane.util.IVector)
     */
    public IMatrix expandTensor(IVector a) {
        IMatrix Tensor = new IMatrix(3,3);
        Tensor.setZero();
        Tensor.setElement(0,0,a.getElement(0));
        Tensor.setElement(0,1,a.getElement(1));
        Tensor.setElement(0,2,a.getElement(2));
        Tensor.setElement(1,0,a.getElement(1));
        Tensor.setElement(2,0,a.getElement(2));
        return Tensor;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#reduceVector(br.ufmg.dees.insane.util.IVector)
     */
    public IVector reduceVector(IVector a) {
        IVector Vector = new IVector(3);
        Vector.zero();
        Vector.setElement(0,a.getElement(0));
        Vector.setElement(1,a.getElement(3));
        Vector.setElement(2,a.getElement(4));
        return Vector;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#reduceTensor(br.ufmg.dees.insane.util.IMatrix)
     */
    public IVector reduceTensor(IMatrix a) {
        IVector Vector = new IVector(3);
        Vector.zero();
        Vector.setElement(0,a.getElement(0,0));
        Vector.setElement(1,a.getElement(0,1));
        Vector.setElement(2,a.getElement(0,2));
        return Vector;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getLabel()
     */
    public String getLabel() {
        return "EulerPoint";
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDominion()
     */
    public int getDominion() {
        return 3;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getIntegrationFactor(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix, java.util.ArrayList)
     */
    public double getIntegrationFactor(IVector n, IMatrix cN, GeometricProperties gps) {
        return 1.0;
    }

	/* (non-Javadoc)
	 * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDOFLabels(int)
	 */
	public ArrayList getDOFLabels(int n) {
		ArrayList <PointValues> al = new ArrayList<PointValues>();
		PointValues spv = new StringPointValues();
	    spv.addPointValue("Wx");
	    spv.addPointValue("Wy");
	    spv.addPointValue("Wz");
		for(int i=0; i<n; i++) {
			al.add(i,spv);
		}
		return al;
	}

}
